fix: #27 stop the deploy job failing and silently skipping the API restart #39
+51
−11
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Why
Rachel: "deployen feilet etter forrige merge når CI skulle restarte GraphQL API-et. Ser ut som det også er noe rart med sjekken av crate-api.service ... for to dager siden ble den skippet selv om servicen allerede fantes."
Both symptoms are real and they have different causes.
Bug 1: the check skipped a service that was there
if systemctl list-unit-files | grep -q '^crate-api.service'; thengrep -qexits at the first match and closes the pipe.systemctlthen gets SIGPIPE, printsFailed to print table: Broken pipeand exits 1. Withpipefailthe whole pipeline returns 1, so theiftakes the else branch and reports "crate-api.service not installed yet, skipping" while the unit is sitting right there in/etc/systemd/system/.Whether it matched was a race on how much
systemctlhad flushed beforegrepclosed the pipe. That is the intermittency.I reproduced it in isolation:
iftook THENiftook ELSEReplaced with
[ -f /etc/systemd/system/crate-api.service ]. No pipe, no SIGPIPE, nopipefailinteraction.Bug 2:
sudocannot authenticateFrom run #11 on the merge of #36:
The self-hosted runner has no TTY. This needs a NOPASSWD rule on the VM, which is not a change I can make in this file. One command, called out in the PR comment.
Frontend publishing happens before this step and was always fine, which is why the site looked deployed while the job was red.
Bug 3, latent: it would have restarted stale code
crate-api.serviceon the VM hasWorkingDirectory=/home/erikhfj/T19-Project-2/serverandExecStart=…/node dist/index.js. That is the prototype I rsynced to the VM on 23 Sep, still sitting there.server/does not exist onmainuntil M2. So a fixedsudowould have restarted the wrong process.The step now also gates on
server/being in the repository:crate-api.serviceabsent, orserver/absent -> skip, with the reason printedserver/present butserver/dist/index.jsmissing -> fail loudly, that is a real build problemWhat was tested
The four decision paths were exercised directly:
YAML parses,
prettierclean, and the job structure is unchanged apart from the one step.What this does not fix
Deploying the server is M2 work. Right now the deploy job only publishes the frontend and deliberately does not touch
crate-api. Whenserver/lands, this step will start restarting it, and M2 needs to add the step that copies the server build to the path the unit expects.Closes
Addresses the deploy half of #27. The workflow is already on
mainfrom #37.